package io.github.talelin.latticy.common.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @authoer:wulongbo
 * @createDate:2022/5/26
 * @description:
 */
@Component
public class TokenRelayRequestInterceptor implements RequestInterceptor {

    @Autowired
    private HttpServletRequest request;

    @Override
    public void apply(RequestTemplate template) {
        String token = AuthorizeVerifyResolverImpl.verifyHeader(request);
        template.header(AuthorizeVerifyResolverImpl.AUTHORIZATION_HEADER,
                "Bearer "+ token);
    }
}

